<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('道具表列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <input type="hidden" id="parentId" name="parentId" th:value="${toolId}"/>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="addParent()"  >
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" >
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/courseTool";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "道具表",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                // {
                //     field: 'deleted',
                //     title: '是否删除 0：否，1是'
                // },
                // {
                //     field: 'comment',
                //     title: '道具备注'
                // },
                // {
                //     field: 'count',
                //     title: '道具數量'
                // },
                // {
                //     field: 'imgCount',
                //     title: '道具图片数量'
                // },
                {
                    field: 'title',
                    title: '道具名字'
                },
                {
                    field: 'imgUrl',
                    title: '道具',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (row.type == 'txt'){
                            return row.imgUrl;
                        }
                        if (row.type == 'image'){
                            return '<img src="'+row.imgUrl+'" height="150" width="150">';
                        }
                        // if (row.type == 'radio'){
                        //     return '<embed height="150" width="100" src="'+row.imgUrl+'">';
                        // }
                        // if (row.type == 'video'){
                        //     return '<video height="150" width="150" controls>  <source src="'+row.imgUrl+'" type="video/mp4"></video>';
                        // }
                        return '<a href="'+row.imgUrl+'">点击查看</a>';
                    }
                },
                {
                    field: 'cover',
                    title: '封面',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (row.cover != "" && row.cover != null){
                            if (row.coverType == 'image' || row.coverType == 'txt' ){
                                return '<img src="'+row.cover+'" height="150" width="150">';
                            }
                            return '<a href="'+row.cover+'">点击查看</a>';
                        }
                    }
                },
                // {
                //     field: 'unit',
                //     title: '道具单位'
                // },
                // {
                //     field: 'url',
                //     title: '推荐购买链接'
                // },
                {
                    field: 'ascription',
                    title: '资源归属'
                },
                {
                    field: 'monthAge',
                    title: '月龄阶段'
                },
                {
                    field: 'application',
                    title: '教具应用目标'
                },
                {
                    field: 'applicationType',
                    title: '教具应用使用方式及建议'
                },
                {
                    field: 'comment',
                    title: '标签'
                },
                {
                    field: 'created',
                    title: '创建时间'
                },
                {
                    field: 'createdName',
                    title: '创建人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs  " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs  " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function addParent() {
        var parentId = $('#parentId').val();
        var url = prefix + '/addParent?id=' + parentId;
        $.modal.open("添加周", url);
    }

</script>
</body>
</html>